package com.magic.interview.模拟.LC1763最长的美好子字符串;

/**
 * @author laoma
 * @create 2022-02-01 9:37
 */
public class Solution {
    public String longestNiceSubstring(String s) {
        int n = s.length();
        int maxPos = 0;
        int maxLen = 0;
        for (int i = 0; i < n; i++) {
            int lower = 0;
            int upper = 0;
            for (int j = i; j < n; j++) {
                if (Character.isLowerCase(s.charAt(j))) {
                    lower |= 1 << (s.charAt(j) - 'a');
                } else {
                    upper |= 1 << (s.charAt(j) - 'A');
                }
                if (lower == upper && j - i + 1 > maxLen) {
                    maxPos = i;
                    maxLen = j - i + 1;
                }
            }
        }
        return s.substring(maxPos, maxLen + maxPos);
    }

    public static void main(String[] args) {
        int lower= 0;
        char ch = 'b';
        lower |= 1 << (ch - 'a');
        System.out.println(lower);
        var a = 5;
        a|=3;
        System.out.println(a);
    }
}
